<template>
	<view>
		<view class="header">
			<image src="@/static/zuo.png" mode="" style="width: 45upx;height: 45upx;" @click="back"></image>
			<text style="font-size: 36upx;padding-right: 350upx;color: #333;">求职期望</text>
			<text style="font-size: 36upx;padding-right: 50upx;color: #333;" @click="queding">确定</text>
		</view>
		<view class="list" style="margin-top: 100upx;">
			<view class="items"
				style="display: flex;justify-content: flex-start;flex-direction: column;align-items: flex-start;">
				<text style="color: #999;font-size: 26upx;">期望城市</text>

				<view @click="tocity">
					<text>{{city_id}}</text>
					<image src="../../../static/tuo.png" mode=""
						style="width: 30upx;height: 30upx;padding-right: 0upx;"></image>
				</view>
			</view>
		</view>
		<view class="list" style="position: relative;">
			<text style="color: #999;font-size: 26upx;">期望职位</text>

			<view @click="shows">
				<text>{{zhiwei}}</text>
				<image src="../../../static/tuo.png" mode="" style="width: 30upx;height: 30upx;padding-right: 0upx;">
				</image>
			</view>
			<view class="onelist" v-show="isZhi">
				<h3>职位名称</h3>
				<view class="twolist" v-for="item in zhilist" @click="show(item.id)">
					<text>{{item.name}}</text>
					<image src="../../../static/tuo.png" mode=""
						style="width: 30upx;height: 30upx;padding-right: 0upx;">
					</image>
				</view>
			</view>
			<jobSelect ref="jobSelect" :listData="listData" @confirem="confiremJob"></jobSelect>
		</view>
		<view class="list">
			<text style="color: #999;font-size: 26upx;">薪资要求</text>

			<view @tap="openLevel">
				<text>{{pickerText}}</text>
				<image src="../../../static/tuo.png" mode="" style="width: 30upx;height: 30upx;padding-right: 0upx;">
				</image>
			</view>

			<level-linkage ref="levelLinkage" :pickerValueDefault="pickerValueDefault" :allData="treeData"
				@onConfirm="onConfirms" themeColor='#007AFF'></level-linkage>
		</view>
		<view class="mask" v-show="isZhi" @click="isZhi=false" style="text-align: center;">
			<text style="padding-top: 500px;display: inline-block;">点击空白区域即可返回</text>
		</view>
	</view>
</template>

<script>
	import jobSelect from '@/components/yunmiao-jobSelect/yunmiao-jobSelect.vue'
	import levelLinkage from "@/components/three-level-linkage/linkage.nvue"
	export default {
		data() {
			return {
				city_id: '选择城市',
				useid: '',
				zhiwei: '请选择',
				isZhi: false,
				zhilist: [],
				listData: [],
				position_id: '',
				salary: '',
				pickerText: '请选择',
				pickerValueDefault: [0, 0],
				treeData: [{
						"id": "1",
						"name": "1K",
						"code": "11",
						"children": [{
								"id": "1230040276324601851",
								"name": "1K",
								"code": "10001",
							},
							{
								"id": "1230040276324601852",
								"name": "2K",
								"code": "10001",
							},
							{
								"id": "1230040276324601853",
								"name": "3K",
								"code": "10001",
							},
							{
								"id": "1230040276324601854",
								"name": "4K",
								"code": "10001",
							},
						]
					},
					{
						"id": "2",
						"name": "3K",
						"code": "12",
						"children": [{
								"id": "1230040276324601854",
								"name": "4K",
								"code": "10001",
							},
							{
								"id": "1230040276324601",
								"name": "5K",
								"code": "10001",
							},
							{
								"id": "1230040276324606",
								"name": "6K",
								"code": "10001",
							},
							{
								"id": "1230040276324607",
								"name": "7K",
								"code": "10001",
							},
							{
								"id": "1230040276324608",
								"name": "8K",
								"code": "10001",
							},
						]
					},
					{
						"id": "3",
						"name": "5K",
						"code": "13",
						"children": [{
								"id": "1230040276324606",
								"name": "6K",
								"code": "10001",
							},
							{
								"id": "1230040276324607",
								"name": "7K",
								"code": "10001",
							},
							{
								"id": "1230040276324608",
								"name": "8K",
								"code": "10001",
							},
							{
								"id": "1230040276324608",
								"name": "9K",
								"code": "10001",
							},
							{
								"id": "12300402763210",
								"name": "10K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "11K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "12K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "13K",
								"code": "10001"
							},
						]
					},
					{
						"id": "4",
						"name": "7K",
						"code": "13",
						"children": [{
								"id": "1230040276324608",
								"name": "8K",
								"code": "10001",
							},
							{
								"id": "1230040276324608",
								"name": "9K",
								"code": "10001",
							},
							{
								"id": "12300402763210",
								"name": "10K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "11K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "12K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "13K",
								"code": "10001"
							},
							{
								"id": "1230040276324608",
								"name": "8K",
								"code": "10001",
							},	
								{
									"id": "1230040276324608",
									"name": "9K",
									"code": "10001",
								},
							{
								"id": "12300402763210",
								"name": "10K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "11K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "12K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "13K",
								"code": "10001"
							},
							{
								"id": "12300402763215",
								"name": "15K",
								"code": "10001"
							},
							{
								"id": "12300402763216",
								"name": "16K",
								"code": "10001"
							},
							{
								"id": "12300402763217",
								"name": "17K",
								"code": "10001"
							},
							{
								"id": "12300402763218",
								"name": "18K",
								"code": "10001"
							},
						]
					},
					{
						"id": "5",
						"name": "9K",
						"code": "13",
						"children": [{
								"id": "12300402763210",
								"name": "10K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "11K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "12K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "13K",
								"code": "10001"
							},
							{
								"id": "12300402763215",
								"name": "15K",
								"code": "10001"
							},
							{
								"id": "12300402763216",
								"name": "16K",
								"code": "10001"
							},
							{
								"id": "12300402763217",
								"name": "17K",
								"code": "10001"
							},
							{
								"id": "12300402763218",
								"name": "18K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "20K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "21K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "22K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "23K",
								"code": "10001"
							},
						]
					},
					{
						"id": "6",
						"name": "11K",
						"code": "13",
						"children": [{
								"id": "12300402763210",
								"name": "12K",
								"code": "10001"
							},
							{
								"id": "12300402763210",
								"name": "13K",
								"code": "10001"
							},
							{
								"id": "12300402763215",
								"name": "15K",
								"code": "10001"
							},
							{
								"id": "12300402763216",
								"name": "16K",
								"code": "10001"
							},
							{
								"id": "12300402763217",
								"name": "17K",
								"code": "10001"
							},
							{
								"id": "12300402763218",
								"name": "18K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "20K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "21K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "22K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "23K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "25K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "26K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "27K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "28K",
								"code": "10001"
							},
						]
					},
					{
						"id": "7",
						"name": "15K",
						"code": "13",
						"children": [{
								"id": "12300402763216",
								"name": "16K",
								"code": "10001"
							},
							{
								"id": "12300402763217",
								"name": "17K",
								"code": "10001"
							},
							{
								"id": "12300402763218",
								"name": "18K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "20K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "21K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "22K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "23K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "25K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "26K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "27K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "28K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "30K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "31K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "32K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "33K",
								"code": "10001"
							},
						]
					},
					{
						"id": "8",
						"name": "17K",
						"code": "13",
						"children": [{
								"id": "12300402763218",
								"name": "18K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "20K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "21K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "22K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "23K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "25K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "26K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "27K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "28K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "30K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "31K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "32K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "33K",
								"code": "10001"
							},
							{
								"id": "12300402763220",
								"name": "35K",
								"code": "10001"
							},
							{
								"id": "12300402763221",
								"name": "36K",
								"code": "10001"
							},
							{
								"id": "12300402763222",
								"name": "37K",
								"code": "10001"
							},
							{
								"id": "12300402763223",
								"name": "38K",
								"code": "10001"
							},
						]
					},
				
				],
			}
		},
		components: {
			jobSelect,
			levelLinkage,
		},
		onLoad(option) {
			this.useid = option.useid
			if( option.city_id){
				this.city_id = option.city_id
			}else{
				uni.request({
					url: 'https://dsx.cdzer.com/api/MemberInfo/getuserinfo', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						uid: option.useid
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
					},
					success: (res) => {
						console.log(res, "sdadasdasdas")
						this.userinfos =  res.data.data
						if(res.data.data.city_name){
							this.city_id = res.data.data.city_name
						}
						if(res.data.data.pos_name){
							this.zhiwei = res.data.data.pos_name
						}
						
						if(res.data.data.salary){
							this.pickerText = res.data.data.salary
						}else{
							this.pickerText = '请选择'
						}
					}
				});
			}
			if(option.zhiwei){
				this.zhiwei = option.zhiwei
			}
			if(option.xinzi){
				this.pickerText = option.xinzi
			}else{
				this.pickerText = '请选择'
			}
			uni.request({
				url: 'https://dsx.cdzer.com/api/Job/getposition', //仅为示例，并非真实接口地址。
				method: 'POST',
				header: {
					'content-type': 'application/x-www-form-urlencoded',
				},
				success: (res) => {
					console.log(res, "职位分类列表")
					this.zhilist = res.data.data
				}
			});
			
		},
		methods: {
			queding(){
				const data = {
					position_id:this.position_id,
					city_name:this.city_id,
					salary:this.pickerText
				};
				this.$http.qzw(data).then(res => {
					if (res.status == 200) {
						console.log(res, "保存资料")
						this.$hideLoading()
						uni.showToast({
							title: res.mess
						})
						setTimeout(() => {
							uni.navigateTo({
								url:`./index?useid=${this.useid}`
							})
						}, 1200)
					} else {
						uni.showToast({
							title: res.mess,
							icon: 'none'
						})
					}
				})
			},
			openLevel() {
				this.$refs.levelLinkage.open();

			},
			onConfirms(e) {
				// e 确认后选中的数据
				this.pickerText = e.name
				this.salary = e.name
				console.log(e.name, "看看")
			},
			// 选择职位
			confiremJob(e) {
				console.log(e)
				this.zhiwei = e.name
				this.isZhi = false
				this.position_id = e.id

			},
			show(id) {
				this.zhiweiId = id
				uni.request({
					url: 'https://dsx.cdzer.com/api/Job/getpositionlist', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						cate_id: id
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
					},
					success: (res) => {
						console.log(res, "岗位列表")
						if (res.data.status == 200) {
							this.listData = res.data.data
							this.$refs.jobSelect.show()
						}
					}
				});
			},
			shows() {
				this.isZhi = true

			},
			back() {
				uni.navigateTo({
					url:`./index?useid=${this.useid}`
				})
				// uni.navigateBack({
				// 	delta:1
				// })
			},
			tocity() {
				console.log(this.pickerText,this.zhiwei)
				uni.navigateTo({
					url: `./city?useid=${this.useid}&zhiwei=${this.zhiwei}&xinzi=${this.pickerText}`
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.mask {
		width: 100%;
		height: 100%;
		position: fixed;
		background: rgba(0, 0, 0, 0.2);
		top: 0;
		left: 0;
		z-index: 100;
		cursor: pointer;
		transition: all 0.15s;
	}

	.onelist {
		width: 100%;
		// height: 500upx;
		z-index: 102;
		background-color: #FFFFFF;
		position: fixed;
		// z-index: 66;
		top: 0upx;
		display: flex;
		left: 0;
		padding-bottom: 40upx;
		flex-direction: column;

		.twolist {
			display: flex;
			padding: 30upx;
			justify-content: space-between;
			border-bottom: 2upx solid #EEEEEE;
			width: 100%;
		}
	}

	.header {
		position: fixed;
		justify-content: space-between;
		background-color: #fff;
		height: 110upx;
		width: 100%;
		top: 0;
		left: 0;
		display: flex;
		z-index: 100;
		align-items: center;
		padding-left: 30upx;
	}

	.list {
		display: flex;
		flex-direction: column;
		padding: 30upx;
		justify-content: center;
		border-bottom: 2upx solid #EEEEEE;

		.list-z {
			display: flex;
			flex-direction: column;

			.tou {
				font-size: 36upx;
				color: 333333;
				font-weight: 550;
			}
		}

		view {
			padding-top: 15upx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			color: #000;
		}
	}
</style>
